package com.sm.sales_management.controller;



import com.sm.sales_management.domain.Announcement;
import com.sm.sales_management.service.IAnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/announcement")
public class AnnouncementController {

    @Autowired
    IAnnouncementService iAnnouncementService;
    @RequestMapping("/allannouncement")
    public String allannouncement(Model model){
        List<Announcement> announcementList= iAnnouncementService.selectAllAnnouncement();
        model.addAttribute("announcementList",announcementList);
        return "announcement_list";

    }

    @RequestMapping("/toaddann")
    public String toaddann(){

        return "addannouncement";
    }

    @RequestMapping("/addann")
    public String addann(Announcement announcement){
        iAnnouncementService.insertAnnouncement(announcement);
        return "redirect:/announcement/allannouncement";
    }
}
